<template>
  <div class="app-container">
    <!-- 搜索筛选 -->
    <el-form :inline="true" class="filter-form mb8">
      <el-form-item label="电站名称">
        <el-input v-model="queryParams.station" placeholder="请输入电站名称" class="mr10"/>
      </el-form-item>

      <el-form-item label="设备名称">
        <el-input v-model="queryParams.device" placeholder="请输入设备名称" class="mr10"/>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" @click="handleSearch">搜索</el-button>
        <el-button icon="el-icon-refresh" @click="handleReset">重置</el-button>
      </el-form-item>
    </el-form>

    <!-- 操作按钮 -->
    <el-row class="mb8">
      <el-col :span="12">
        <el-button
          type="primary"
          icon="el-icon-plus"
          class="gradient-btn"
          @click="handleAdd"
        >
          新增
        </el-button>
        <el-button
          type="primary"
          icon="el-icon-download"
          class="gradient-btn"
        >
          导出
        </el-button>
      </el-col>
    </el-row>

    <!-- 数据表格 -->
    <el-table :data="inspectionList" style="width: 100%">
      <el-table-column prop="station" label="电站名称" width="120"/>
      <el-table-column prop="device" label="设备名称" width="150"/>
      <el-table-column prop="result" label="检修结果" min-width="180"/>
      <el-table-column prop="type" label="检修类型" width="120"/>
      <el-table-column prop="duration" label="持续时长" width="120">
        <template slot-scope="scope">{{ scope.row.duration }}小时</template>
      </el-table-column>
      <el-table-column prop="operator" label="操作人员" width="120"/>
      <el-table-column prop="timeRange" label="操作时间" width="260"/>
      <el-table-column prop="remark" label="备注" width="150"/>
      <el-table-column label="操作" width="120">
        <template slot-scope="scope">
          <el-button type="text" @click="handleEdit(scope.row)">编辑</el-button>
          <el-button type="text" @click="handleDelete(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <!-- 分页 -->
    <el-pagination
      class="mt20"
      :current-page="pageNum"
      :page-size="10"
      :total="pageTotal"
      layout="total, prev, pager, next"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script>
export default {
  data() {
    return {
      queryParams: {
        station: '',
        device: ''
      },
      inspectionList: [
        {
          station: '电站2',
          device: '西厂后台监控',
          result: '后台监控已恢复正常',
          type: '设备维修',
          duration: 1.50,
          operator: '张三',
          timeRange: '2024-07-12 14:00:57 至 2024-07-12 16:00:06',
          remark: '更换监控主机'
        }
      ],
      pageNum: 1,
      pageTotal: 10
    }
  },
  methods: {
    handleSearch() {
      // 调用接口查询
    },
    handleReset() {
      this.queryParams = { station: '', device: '' }
    },
    handleAdd() {
      // 新增逻辑
    },
    handleEdit(row) {
      // 编辑逻辑
    },
    handleDelete(row) {
      // 删除逻辑
    },
    handleSizeChange(val) {
      // 分页大小变化
    },
    handleCurrentChange(val) {
      // 页码变化
    }
  }
}
</script>

<style scoped>
.filter-form {
  background: #f5f7fa;
  padding: 20px;
  border-radius: 4px;
}

.gradient-btn {
  background: linear-gradient(45deg, #1be5e7, #2571e9);
  border: none;
  color: #fff;
}

::v-deep .el-table {
  background: transparent;
}
</style>
